import { SwipeCell } from 'vant'
import { createBEM } from '../../../components/VanField'

const bem = createBEM('van-swipe-cell')
export default {
  extends: SwipeCell,
  render() {
    const wrapperStyle = {
      transform: `translate3d(${this.offset}px, 0, 0)`,
      transitionDuration: this.dragging ? '0s' : '.6s'
    }

    const { onTouchStart, onTouchEnd, onTouchMove } = this

    return (
      <div class={bem()} onClick={this.getClickHandler('cell')} {...{ onTouchStart, onTouchEnd, onTouchMove }}>
        <div class={bem('wrapper')} style={wrapperStyle}>
          {this.genLeftPart()}
          {this.slots()}
          {this.genRightPart()}
        </div>
      </div>
    )
  }
}
